package com.foreknow.tijian.controller;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.foreknow.tijian.po.Setmeal;
import com.foreknow.tijian.service.SetmealService;
import com.foreknow.tijian.service.Impl.SetmealServiceImpl;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

public class SetmealController  {
    public Object listSetmealByType(HttpServletRequest request) {
        //1.获取前台的请求参数
        int type=Integer.parseInt(request.getParameter("type"));
        //2.调用Service当中的方法
        //先创建Service当中的对象
        SetmealService setmealService=new SetmealServiceImpl();
        //转成int类型
        // int orderTypeId=Integer.parseInt(orderTypedId);
        List<Setmeal> list=setmealService.getSetmealByType(type);
        return list;
    }

    public Object getSetmealById(HttpServletRequest request) {
        Setmeal setmeal=new Setmeal();
        int smId=Integer.parseInt(request.getParameter("smId"));
        if(smId!=0){
            setmeal.setSmId(smId);
        }
        SetmealService setmealService=new SetmealServiceImpl();
        setmeal= setmealService.getSetmealById(setmeal);
        return setmeal;
    }
}
